import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:stop_watch_timer/stop_watch_timer.dart';
import 'package:yp/config/index.dart';
import 'package:yp/config/style.dart';
import 'package:yp/router.dart';
import 'package:yp/util/util.dart';
import 'package:yp/widgets/bottom_sheet.dart';
import 'package:yp/widgets/button_widget.dart';
import 'package:yp/widgets/cache_image.dart';
import 'package:yp/widgets/dialog.dart';
import 'package:yp/widgets/line.dart';
import 'package:yp/widgets/navigation_bar.dart';
import 'package:yp/widgets/shop.dart';
import 'package:yp/widgets/switch.dart';

/// 订单详情
class OrderDetail extends StatefulWidget {
  final Map arguments;
  const OrderDetail({Key key, this.arguments}) : super(key: key);
  @override
  _OrderDetailState createState() => _OrderDetailState();
}

class _OrderDetailState extends State<OrderDetail>
    with SingleTickerProviderStateMixin {
  AnimationController _controller;
  bool _switchTest = false;

  /// 1 待支付 2 待支付尾款 3 待发货 4 待收货 5 派送中 6 订单完成
  int _pagetype = 2;

  final StopWatchTimer _stopWatchTimerDown = StopWatchTimer(
    mode: StopWatchMode.countDown,
    presetMillisecond: StopWatchTimer.getMilliSecFromHour(3),
    onEnded: () {
      print('onEnded');
    },
  );
  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this);
    _stopWatchTimerDown.onExecute.add(StopWatchExecute.start);
    print(widget.arguments);
  }

  @override
  void dispose() async {
    super.dispose();
    _controller.dispose();
    await _stopWatchTimerDown.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: YPNavigationBar('订单详情'),
      body: Padding(
        padding:
            EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom + 60),
        child: CustomScrollView(
          slivers: [
            SliverToBoxAdapter(
              child: Column(
                children: [
                  _header(_pagetype),
                  _pagetype == 5 ? _logistics() : SizedBox(),
                  _address(),
                  YpLine(),
                  _pickUp(),
                  YpLine(
                      height: 20,
                      thickness: 20,
                      color: EsColors.BackGroundSecondary),
                  _goodsInfo(),
                  YpLine(
                      height: 20,
                      thickness: 20,
                      color: EsColors.BackGroundSecondary),
                  _deliverInfo(),
                  YpLine(
                      height: 20,
                      thickness: 20,
                      color: EsColors.BackGroundSecondary),
                  _orderInfo(),
                  YpLine(
                      height: 20,
                      thickness: 20,
                      color: EsColors.BackGroundSecondary),
                  _pagetype == 2 ? _continuePay() : _amount()
                ],
              ),
            )
          ],
        ),
      ),
      floatingActionButton: _bottom(),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      backgroundColor: EsColors.White,
    );
  }

  /// 头部支付or物流状态
  Widget _header(int type) {
    return Container(
      color: EsColors.Pink.withOpacity(0.1),
      alignment: Alignment.center,
      padding: const EdgeInsets.symmetric(horizontal: 20),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Padding(
            padding: const EdgeInsets.only(top: 25, bottom: 10),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Visibility(
                  visible: type != 6,
                  child: Image(
                    image: AssetImage('assets/images/orderdetial.png'),
                    width: 48.w,
                  ),
                ),
                SizedBox(width: 10),
                Text(
                  _headerText(type),
                  style: TextStyle(
                      color: EsColors.Primary,
                      fontSize: EsSizes.LG,
                      fontWeight: EsFontWeights.Medium),
                ),
                SizedBox(width: 4),
                Icon(
                  Icons.arrow_forward_ios,
                  size: EsSizes.SM,
                  color: EsColors.Primary,
                ),
              ],
            ),
          ),
          _tips(type),
          SizedBox(height: 15)
        ],
      ),
    );
  }

  /// 物流信息
  Widget _logistics() {
    return Column(
      children: [
        Container(
          color: EsColors.White,
          padding: EdgeInsets.symmetric(horizontal: 12),
          child: Row(
            children: [
              Expanded(
                child: Row(
                  children: [
                    Image(
                        image: AssetImage('assets/images/level.png'),
                        width: 25,
                        fit: BoxFit.fitWidth),
                    SizedBox(width: 6),
                    GestureDetector(
                      behavior: HitTestBehavior.opaque,
                      onTap: () {
                        print('打快递电话');
                      },
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: [
                          Text('中通快递',
                              style: TextStyle(
                                  color: EsColors.TitleSecondary,
                                  fontSize: EsSizes.MD,
                                  fontWeight: EsFontWeights.Medium)),
                          Row(
                            children: [
                              Text('官方电话 95311',
                                  style: TextStyle(
                                      color: EsColors.TitleSecondary,
                                      fontSize: EsSizes.SM,
                                      fontWeight: EsFontWeights.Normal)),
                              Icon(
                                Icons.arrow_forward_ios,
                                size: EsSizes.XS,
                                color: EsColors.TitleSecondary,
                              ),
                            ],
                          ),
                        ],
                      ),
                    )
                  ],
                ),
              ),
              Container(
                  color: EsColors.BackGroundSecondary, width: 1, height: 70),
              SizedBox(width: 12),
              Expanded(
                child: GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  onTap: () {
                    print('复制快递单号');
                    Clipboard.setData(ClipboardData(text: '121212121212121'))
                        .then((value) => toast('复制成功'));
                  },
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      Text('快递编号',
                          style: TextStyle(
                              color: EsColors.TitleSecondary,
                              fontSize: EsSizes.XS,
                              fontWeight: EsFontWeights.Normal)),
                      Row(
                        children: [
                          Text('211985211211985211',
                              style: TextStyle(
                                  color: EsColors.TitleSecondary,
                                  fontSize: EsSizes.XS,
                                  fontWeight: EsFontWeights.Normal)),
                          Expanded(child: SizedBox()),
                          EsOutLineButton(
                            '复制',
                            onTap: () {
                              print('复制快递单号');
                              Clipboard.setData(
                                  ClipboardData(text: '121212121212121'));
                            },
                            fontSize: EsSizes.XXS,
                            normal: true,
                            padding: EdgeInsets.symmetric(
                                vertical: 1, horizontal: 4),
                          )
                        ],
                      ),
                    ],
                  ),
                ),
              ),
            ],
          ),
        ),
        YpLine(height: 20, thickness: 20, color: EsColors.BackGroundSecondary),
      ],
    );
  }

  /// 头部对应的文字
  String _headerText(int type) {
    switch (type) {
      case 1:
        return '待支付';
        break;
      case 2:
        return '待支付尾款';
        break;
      case 3:
        return '待发货';
        break;
      case 4:
        return '待收货';
        break;
      case 5:
        return '派送中';
        break;
      case 6:
        return '订单完成';
        break;
      default:
        return '';
    }
  }

  /// 下边提示 对应的文字
  Widget _tips(int type) {
    switch (type) {
      case 1:
      case 2:
        return StreamBuilder<int>(
          stream: _stopWatchTimerDown.rawTime,
          initialData: _stopWatchTimerDown.rawTime.value,
          builder: (context, snap) {
            final value = snap.data;
            final displayTime = StopWatchTimer.getDisplayTime(value,
                hours: true, milliSecond: false);
            return Container(
              decoration:
                  BoxDecoration(borderRadius: BorderRadius.circular(20.0)),
              padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
              child: Text(
                (type == 1 ? '支付倒计时：' : '待支付尾款') + displayTime,
                style: TextStyle(
                    color: EsColors.Primary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal),
              ),
            );
          },
        );
        break;
      case 4:
      case 5:
        return Text(
          type == 4 ? '订单已发货，请注意查收' : '快递交给小哥，正在派送中(联系电话：135****3333),请耐心等待',
          maxLines: 1,
          overflow: TextOverflow.ellipsis,
          style: TextStyle(
              color: EsColors.Primary,
              fontSize: EsSizes.SM,
              fontWeight: EsFontWeights.Normal),
        );
      case 3:
      case 6:
      default:
        return SizedBox();
    }
  }

  /// 地址信息
  Widget _address() {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 12),
      child: Column(
        children: [
          Row(
            children: [
              Container(
                  padding: EdgeInsets.all(5),
                  decoration: BoxDecoration(
                      color: EsColors.Primary,
                      borderRadius: BorderRadius.circular(30)),
                  child: Icon(Icons.location_on, color: EsColors.White)),
              SizedBox(width: 12),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: [
                    SizedBox(height: 8),
                    Row(
                      children: [
                        Container(
                          constraints: BoxConstraints(
                              maxWidth: MediaQuery.of(context).size.width / 3),
                          child: Text(
                            '爱新觉罗',
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(
                                color: EsColors.TitleSecondary,
                                fontSize: EsSizes.MD,
                                fontWeight: EsFontWeights.Medium),
                          ),
                        ),
                        SizedBox(width: 12),
                        Text(
                          '128****3321',
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          style: TextStyle(
                              color: EsColors.TitleSecondary,
                              fontSize: EsSizes.MD,
                              fontWeight: EsFontWeights.Medium),
                        ),
                      ],
                    ),
                    SizedBox(height: 6),
                    Text(
                      '江苏省 苏州市 昆山市 花桥镇 绿地大道211号 启航城晶彩小区 36号402室',
                      maxLines: 2,
                      overflow: TextOverflow.ellipsis,
                      style: TextStyle(
                          color: EsColors.TitleSecondary,
                          fontSize: EsSizes.SM,
                          fontWeight: EsFontWeights.Normal),
                    ),
                    SizedBox(height: 8),
                  ],
                ),
              ),
              SizedBox(width: 8),
              EsTextButton(
                '修改',
                textColor: EsColors.Primary,
                fontSize: EsSizes.XS,
                onTap: () {
                  print('修改地址');
                },
              ),
            ],
          ),
          SizedBox(height: 4),
          Visibility(
            visible: _switchTest,
            child: Text(
              '您已经选择自提，商品到达自提点后凭借提货码提货',
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(
                  color: EsColors.Pink,
                  fontSize: EsSizes.XS,
                  fontWeight: EsFontWeights.Normal),
            ),
          ),
        ],
      ),
    );
  }

  /// 自提
  Widget _pickUp() {
    return Container(
      color: EsColors.White,
      padding: const EdgeInsets.fromLTRB(12, 4, 12, 10),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Row(children: [
            Expanded(
              child: Text(
                '您可以选择附近的自提点去提货',
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                    color: EsColors.Content,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal),
              ),
            ),
            SizedBox(width: 12),
            EsSwitch(
                status: _switchTest,
                onChanged: (bool value) {
                  setState(() {
                    _switchTest = !_switchTest;
                  });
                  print('点击提货开关：${_switchTest ? '开' : '关'}');
                }),
          ]),
          Visibility(
            visible: _switchTest,
            child: Padding(
              padding: const EdgeInsets.only(bottom: 12),
              child: Row(
                children: [
                  Expanded(
                    child: Text(
                      '河南省 郑州市 管城回族自治区商鼎路龙宇国际12号楼1201室',
                      maxLines: 2,
                      overflow: TextOverflow.ellipsis,
                      style: TextStyle(
                          color: EsColors.TitleSecondary,
                          fontSize: EsSizes.SM,
                          fontWeight: EsFontWeights.Normal),
                    ),
                  ),
                  SizedBox(width: 12),
                  EsOutLineButton(
                    '修改',
                    normal: true,
                    textColor: EsColors.ContentSecondary,
                    padding: EdgeInsets.symmetric(vertical: 4, horizontal: 12),
                    onTap: () {
                      print('修改自提货点');
                      YpShowDialog.showPickUpStation(context, [
                        {'isSelect': false, 'name': '农业南路进水营业厅'},
                        {'isSelect': true, 'name': ''},
                        {'isSelect': false, 'name': '农业南路进水营业厅'},
                        {'isSelect': true, 'name': '农业南路进水营业厅'},
                        {'isSelect': false, 'name': ''}
                      ], (index, text, {info}) {
                        print(index);
                        print(text);
                      });
                    },
                  )
                ],
              ),
            ),
          ),

          /// 彩线
          Visibility(
              visible: _switchTest, child: YpLine(height: 4, thickness: 4)),
        ],
      ),
    );
  }

  /// 店铺&商品信息
  Widget _goodsInfo() {
    return Column(
      children: [
        ShopName('嘉定安亭嘉亭荟店'),
        YpLine(),
        ListView.separated(
            padding: EdgeInsets.zero,
            physics: NeverScrollableScrollPhysics(),
            shrinkWrap: true,
            itemBuilder: (context, index) {
              return _goodsItem();
            },
            separatorBuilder: (context, index) {
              return YpLine(indent: 12);
            },
            itemCount: 4)
      ],
    );
  }

  /// 商品条目
  Widget _goodsItem() {
    return Padding(
      padding: const EdgeInsets.only(top: 12, left: 12, right: 12, bottom: 10),
      child: Row(children: [
        CachedImage(
            width: 70,
            height: 70,
            margin: EdgeInsets.fromLTRB(0, 10, 8, 12),
            scale: BoxFit.cover,
            path:
                'http://imgservice.suning.cn/uimg1/b2c/image/LbK15Wx6ONCA2R1lpJXkOg.jpg_800w_800h_4e'),
        SizedBox(width: 6),
        Expanded(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                '方太（FOTILE）CXW-258-JC7...',
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal),
              ),
              Padding(
                padding: const EdgeInsets.only(top: 2, bottom: 10),
                child: Text(
                  '22超大风量+挥手智控...',
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                  style: TextStyle(
                      color: EsColors.Content,
                      fontSize: EsSizes.XS,
                      fontWeight: EsFontWeights.Normal),
                ),
              ),
              Row(
                children: [
                  Container(
                    constraints: BoxConstraints(
                        maxWidth: MediaQuery.of(context).size.width / 3),
                    child: Text('￥22489.00',
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                            fontSize: EsSizes.MD,
                            color: EsColors.TitleSecondary,
                            fontWeight: EsFontWeights.Medium)),
                  ),
                  SizedBox(width: 10),
                  Text('x1',
                      style: TextStyle(
                          fontSize: EsSizes.SM,
                          color: EsColors.ContentSecondary,
                          fontWeight: EsFontWeights.Normal)),
                  Expanded(child: SizedBox()),
                  Visibility(
                    visible: _pagetype == 3 || _pagetype == 5 || _pagetype == 6,
                    child: EsOutLineButton(
                      '申请售后',
                      normal: true,
                      onTap: () {
                        print('申请售后');
                        Get.toNamed(RouteConfig.afterMarket);
                      },
                    ),
                  ),
                  Visibility(
                    visible: _pagetype == 6,
                    child: Padding(
                      padding: const EdgeInsets.only(left: 8),
                      child: EsOutLineButton(
                        '晒单评价',
                        onTap: () {
                          print('晒单评价');
                        },
                      ),
                    ),
                  )
                ],
              ),
            ],
          ),
        ),
      ]),
    );
  }

  /// 配送信息
  Widget _deliverInfo() {
    return Column(
      children: [
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 12),
          child: Row(
            children: [
              Text('配送类型',
                  style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Expanded(
                child: Text('预约发货',
                    textAlign: TextAlign.end,
                    style: TextStyle(
                      color: EsColors.Title,
                      fontSize: EsSizes.SM,
                      fontWeight: EsFontWeights.Medium,
                    )),
              ),
              SizedBox(width: 4),
              Icon(
                Icons.arrow_forward_ios,
                size: EsSizes.SM,
                color: EsColors.ContentSecondary,
              ),
            ],
          ),
        ),
        YpLine(),
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 12),
          child: Row(
            children: [
              Text('发货时间',
                  style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Expanded(child: SizedBox()),
              Text('2021-09-04',
                  style: TextStyle(
                    color: EsColors.Title,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Medium,
                  )),
              SizedBox(width: 4),
              Icon(
                Icons.arrow_forward_ios,
                size: EsSizes.SM,
                color: EsColors.ContentSecondary,
              ),
            ],
          ),
        ),
      ],
    );
  }

  /// 订单信息
  Widget _orderInfo() {
    return Column(
      children: [
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 12, 12, 4),
          child: Row(
            children: [
              Text('订单编号：',
                  style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Expanded(
                child: Text('121212121212121',
                    style: TextStyle(
                      color: EsColors.Title,
                      fontSize: EsSizes.SM,
                      fontWeight: EsFontWeights.Medium,
                    )),
              ),
              SizedBox(width: 12),
              EsOutLineButton(
                '复制',
                normal: true,
                // fontSize: EsSizes.XXS,
                // textColor: EsColors.Content,
                // bgColor: EsColors.BackGround,
                // borderColor: EsColors.BackGround,
                padding: EdgeInsets.symmetric(vertical: 1, horizontal: 8),
                onTap: () {
                  Clipboard.setData(ClipboardData(text: '121212121212121'));
                  toast('复制成功');
                },
              ),
            ],
          ),
        ),
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 4, 12, 4),
          child: Row(
            children: [
              Text('下单时间：',
                  style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Text('2021-09-04 12:12:12',
                  style: TextStyle(
                    color: EsColors.Title,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Medium,
                  )),
            ],
          ),
        ),
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 4, 12, 4),
          child: Row(
            children: [
              Text('线索编号：',
                  style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Text('23123212',
                  style: TextStyle(
                    color: EsColors.Title,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Medium,
                  )),
            ],
          ),
        ),
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 4, 12, 4),
          child: Row(
            children: [
              Text('商机品类：',
                  style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Expanded(
                child: Text('灶具、热水器',
                    style: TextStyle(
                      color: EsColors.Title,
                      fontSize: EsSizes.SM,
                      fontWeight: EsFontWeights.Medium,
                    )),
              ),
            ],
          ),
        ),
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 4, 12, 4),
          child: Row(
            children: [
              Text('支付方式：',
                  style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Text('支付宝',
                  style: TextStyle(
                    color: EsColors.Title,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Medium,
                  )),
            ],
          ),
        ),
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 4, 12, 4),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text('订单备注：',
                  style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Expanded(
                child: Text('如果缺货：缺货商品退款，其他商品继续配送。这里是我的订单留言，请准时送达哦~',
                    style: TextStyle(
                      color: EsColors.Title,
                      fontSize: EsSizes.SM,
                      fontWeight: EsFontWeights.Medium,
                    )),
              ),
            ],
          ),
        ),
        SizedBox(height: 8)
      ],
    );
  }

  /// 钱部分
  /// 正常的明细
  Widget _amount() {
    return Column(
      children: [
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 12, 12, 6),
          child: Row(
            children: [
              Text('商品金额',
                  style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Expanded(
                child: Text('￥324.22',
                    textAlign: TextAlign.end,
                    style: TextStyle(
                      color: EsColors.Title,
                      fontSize: EsSizes.SM,
                      fontWeight: EsFontWeights.Normal,
                    )),
              ),
            ],
          ),
        ),
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 6, 12, 6),
          child: Row(
            children: [
              Text('积分抵扣',
                  style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Expanded(
                child: Text('-￥10',
                    textAlign: TextAlign.end,
                    style: TextStyle(
                      color: EsColors.Title,
                      fontSize: EsSizes.SM,
                      fontWeight: EsFontWeights.Normal,
                    )),
              ),
            ],
          ),
        ),
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 6, 12, 6),
          child: Row(
            children: [
              Text('配送运费',
                  style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Expanded(
                child: Text('0.00',
                    textAlign: TextAlign.end,
                    style: TextStyle(
                      color: EsColors.Title,
                      fontSize: EsSizes.SM,
                      fontWeight: EsFontWeights.Normal,
                    )),
              ),
            ],
          ),
        ),
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 6, 12, 16),
          child: Row(
            children: [
              Text('实付金额',
                  style: TextStyle(
                    color: EsColors.Title,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Expanded(
                child: Text('￥180.00',
                    textAlign: TextAlign.end,
                    style: TextStyle(
                      color: EsColors.Title,
                      fontSize: EsSizes.MD,
                      fontWeight: EsFontWeights.Medium,
                    )),
              ),
            ],
          ),
        ),
      ],
    );
  }

  /// 继续支付的明细
  Widget _continuePay() {
    return Column(
      children: [
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 12, 12, 6),
          child: Row(
            children: [
              Text('订单总价',
                  style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Expanded(
                child: Text('￥3294.22',
                    textAlign: TextAlign.end,
                    style: TextStyle(
                      color: EsColors.Title,
                      fontSize: EsSizes.SM,
                      fontWeight: EsFontWeights.Medium,
                    )),
              ),
            ],
          ),
        ),
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 6, 12, 6),
          child: Row(
            children: [
              Text('已支付定金',
                  style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Expanded(
                child: Text('￥100',
                    textAlign: TextAlign.end,
                    style: TextStyle(
                      color: EsColors.Title,
                      fontSize: EsSizes.SM,
                      fontWeight: EsFontWeights.Medium,
                    )),
              ),
            ],
          ),
        ),
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 6, 12, 6),
          child: Row(
            children: [
              Text('待支付尾款',
                  style: TextStyle(
                    color: EsColors.Title,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Medium,
                  )),
              Expanded(
                child: Text('￥290.00',
                    textAlign: TextAlign.end,
                    style: TextStyle(
                      color: EsColors.Primary,
                      fontSize: EsSizes.LG,
                      fontWeight: EsFontWeights.Medium,
                    )),
              ),
            ],
          ),
        ),
        Padding(
          padding: const EdgeInsets.fromLTRB(12, 6, 12, 16),
          child: Row(
            children: [
              Text('订单提成',
                  style: TextStyle(
                    color: EsColors.Title,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal,
                  )),
              Expanded(
                child: Text('￥180.00',
                    textAlign: TextAlign.end,
                    style: TextStyle(
                      color: EsColors.Primary,
                      fontSize: EsSizes.LG,
                      fontWeight: EsFontWeights.Medium,
                    )),
              ),
            ],
          ),
        ),
      ],
    );
  }

  /// 底部按钮
  Widget _bottom() {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
      decoration: EsDecoration.BoxShadowRadiusUp,
      child: Row(children: [
        Expanded(child: SizedBox()),
        Visibility(
          visible: _pagetype == 2,
          child: Padding(
            padding: const EdgeInsets.only(left: 8),
            child: EsTextButton(
              '发送短信',
              onTap: () {
                print('发送短信');
              },
            ),
          ),
        ),
        Visibility(
          visible: _pagetype == 1 || _pagetype == 2,
          child: Padding(
            padding: const EdgeInsets.only(left: 8),
            child: EsOutLineButton(
              '取消订单',
              normal: true,
              fontSize: EsSizes.SM,
              padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
              onTap: () {
                print('取消订单');
                YpBottomSheet.showSelect(
                    context,
                    [
                      '操作有误（商品/时间/地址选错了）',
                      '重复下单',
                      "不想要了",
                      "地址信息填写错误",
                      "商品降价",
                      "其他"
                    ],
                    title: "取消原因",
                    selectIndex: 2, clickCallback: (index, text, {info}) {
                  print(index);
                  print(text);
                });
              },
            ),
          ),
        ),
        Visibility(
          visible: _pagetype == 3 || _pagetype == 4 || _pagetype == 6,
          child: Padding(
            padding: const EdgeInsets.only(left: 8),
            child: EsOutLineButton(
              '查看发票',
              normal: true,
              fontSize: EsSizes.SM,
              padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
              onTap: () {
                print('查看发票');
              },
            ),
          ),
        ),
        Visibility(
          visible: _pagetype == 3 || _pagetype == 6,
          child: Padding(
            padding: const EdgeInsets.only(left: 8),
            child: EsOutLineButton(
              '评价晒单',
              normal: true,
              fontSize: EsSizes.SM,
              padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
              onTap: () {
                print('评价晒单');
              },
            ),
          ),
        ),
        Visibility(
          visible: _pagetype == 5,
          child: Padding(
            padding: const EdgeInsets.only(left: 8),
            child: EsOutLineButton(
              '补开发票',
              normal: true,
              fontSize: EsSizes.SM,
              padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
              onTap: () {
                print('补开发票');
              },
            ),
          ),
        ),
        Visibility(
          visible: _pagetype == 5,
          child: Padding(
            padding: const EdgeInsets.only(left: 8),
            child: EsOutLineButton(
              '查看物流',
              normal: true,
              fontSize: EsSizes.SM,
              padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
              onTap: () {
                print('查看物流');
              },
            ),
          ),
        ),
        Visibility(
          visible: _pagetype == 3 || _pagetype == 6,
          child: Padding(
            padding: const EdgeInsets.only(left: 8),
            child: EsOutLineButton(
              '申请售后',
              normal: true,
              fontSize: EsSizes.SM,
              padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
              onTap: () {
                print('申请售后');
                Get.toNamed(RouteConfig.afterMarket);
              },
            ),
          ),
        ),
        Visibility(
          visible: _pagetype == 3 || _pagetype == 6,
          child: Padding(
            padding: const EdgeInsets.only(left: 8),
            child: EsOutLineButton(
              '再来一单',
              textColor: EsColors.White,
              bgColor: EsColors.Primary,
              borderColor: EsColors.Primary,
              fontSize: EsSizes.SM,
              padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
              onTap: () {
                print('再来一单');
              },
            ),
          ),
        ),
        Visibility(
          visible: _pagetype == 4 || _pagetype == 5,
          child: Padding(
            padding: const EdgeInsets.only(left: 8),
            child: EsOutLineButton(
              '确认收货',
              fontSize: EsSizes.SM,
              padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
              onTap: () {
                print('确认收货');
              },
            ),
          ),
        ),
        Visibility(
          visible: _pagetype == 1,
          child: Padding(
            padding: const EdgeInsets.only(left: 8),
            child: EsOutLineButton(
              '立即支付',
              textColor: EsColors.White,
              bgColor: EsColors.Primary,
              borderColor: EsColors.Primary,
              fontSize: EsSizes.SM,
              padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
              onTap: () {
                print('立即支付');
              },
            ),
          ),
        ),
        Visibility(
          visible: _pagetype == 2,
          child: Padding(
            padding: const EdgeInsets.only(left: 8),
            child: EsOutLineButton(
              '去支付尾款',
              textColor: EsColors.White,
              bgColor: EsColors.Primary,
              borderColor: EsColors.Primary,
              fontSize: EsSizes.SM,
              padding: EdgeInsets.symmetric(vertical: 4, horizontal: 10),
              onTap: () {
                print('去支付尾款');
              },
            ),
          ),
        )
      ]),
    );
  }
}
